package de.cbf.cam.dsa.inventory.views;

import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.part.ViewPart;

import de.cbf.cam.dsa.inventory.Activator;
import de.cbf.cam.dsa.inventory.composites.CompositeInventory;

import de.cbf.cam.dsa.model.entities.OneNPC;


public class InventoryView extends ViewPart {

	/**
	 * The ID of the view as specified by the extension.
	 */
	public static final String ID = "de.cbf.cam.dsa.inventory.views.InventoryView";
	
	private CompositeInventory compositeInventory;

	public InventoryView() {
	}

	/**
	 * This is a callback that will allow us
	 * to create the viewer and initialize it.
	 */
	public void createPartControl(Composite parent) {
		compositeInventory = new CompositeInventory(parent, SWT.NORMAL);
		compositeInventory.setLayoutData(new GridData(GridData.FILL_BOTH));
		Activator.getDefault().setInventoryView(this);
	}

	
	/**
	 * Passing the focus request to the viewer's control.
	 */
	public void setFocus() {
		
	}

	public void setCharacter(OneNPC character) {
		compositeInventory.setCharacter(character);		
	}

	@Override
	public void dispose() {
		compositeInventory.dispose();
		Activator.getDefault().setInventoryView(null);
		super.dispose();
	}
}